DATA SEGMENT
    GRADE DW 80,59,61
    S DW ?
    A DW ?
    L DW ?
    R DW ?
DATA ENDS

CODE SEGMENT
    ASSUME CS:CODE, DS:DATA

MAIN PROC
    START:
    mov ax,data 
    mov ds,ax 
    CALL SUM
    CALL AVG
    CALL COUNT
    MOV AH,4CH
    INT 21H
MAIN ENDP

SUM PROC FAR
    MOV BX, 0
    MOV AX, 0 
LOP:
    ADD AX, [GRADE+BX]
    ADD BX, 2
    CMP BX, 6
    JNE LOP
    MOV S,AX
    RET
SUM ENDP

AVG PROC FAR
    MOV BX,3
    DIV BX
    MOV A,AX
    RET
AVG ENDP



COUNT PROC FAR
    MOV SI,OFFSET GRADE
    MOV BX,0
    MOV AX,0
    MOV CX,3
JUDGE:
    CMP GRADE[SI],60
    JL L60
    CMP GRADE[SI],90
    JBE R90

R90:ADD AX,1
    ADD SI,2
    LOOP JUDGE

L60:ADD BX,1
    ADD SI,2
    LOOP JUDGE


    MOV L,BX
    MOV R,AX
    RET
COUNT ENDP


CODE ENDS
END START
